﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class user_User : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadAllCategory();

            if (Session["adminlogin"] != null)
            {
                lblUser.Text = Session["adminlogin"].ToString();
                LinkAdmincp.Visible = true;
                LinkExit.Visible = true;
                formlogin1.Visible = false;
            }
            else if (Session["login"] != null)
            {
                lblUser.Text = Session["email"].ToString();
                formlogin1.Visible = false;
                LinkExit.Visible = true;
                LinkAdmincp.Visible = false;
            }
            else if (Session["adminlogin"] == null)
            {
                lblUser.Text = "[Guest]";
                formlogin1.Visible = true;
                LinkExit.Visible = false;
                LinkAdmincp.Visible = false;
            }
        }

        //load mycart
        lb.Text = "(" + ShoppingCart.Instance.Items.Count.ToString() + ")";
        //lblHitCouter.Text = "Hit counter: "+Application["HitCounter"].ToString();
        //lblCounterOnline.Text = "User Online: "+Application["CounterOnline"].ToString();

    }

    public void LoadAllCategory()
    {
        CategoryBus ctBus = new CategoryBus();
        dtListCategory.DataSource = ctBus.GetAllCategory();
        dtListCategory.DataBind();

    }
    protected void LinkExit_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("default.aspx");
    }
    protected void LinkAdmincp_Click(object sender, EventArgs e)
    {
        Response.Redirect("../admin/Default.aspx");
    }

}
